package com.ctsi.ssdc.service.impl;

import com.ctsi.ssdc.entity.IndustrialEconomicIndicators;
import com.ctsi.ssdc.mapper.IndustrialEconomicIndicatorsMapper;
import com.ctsi.ssdc.service.IndustrialEconomicIndicatorsService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import java.util.Date;
import java.util.List;
import java.util.concurrent.Future;
import javax.annotation.Resource;

/**
 * 工业经济主要指标(IndustrialEconomicIndicators)表服务实现类
 *
 * @author makejava
 * @since 2023-03-11 22:08:06
 */
@Service("industrialEconomicIndicatorsService")
public class IndustrialEconomicIndicatorsServiceImpl implements IndustrialEconomicIndicatorsService {
    @Resource
    private IndustrialEconomicIndicatorsMapper industrialEconomicIndicatorsMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public IndustrialEconomicIndicators queryById(Long id) {
        return this.industrialEconomicIndicatorsMapper.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param industrialEconomicIndicators 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<IndustrialEconomicIndicators> queryByPage(IndustrialEconomicIndicators industrialEconomicIndicators, PageRequest pageRequest) {
        long total = this.industrialEconomicIndicatorsMapper.count(industrialEconomicIndicators);
        return new PageImpl<>(this.industrialEconomicIndicatorsMapper.queryAllByLimit(industrialEconomicIndicators, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param industrialEconomicIndicators 实例对象
     * @return 实例对象
     */
    @Override
    public IndustrialEconomicIndicators insert(IndustrialEconomicIndicators industrialEconomicIndicators) {
        this.industrialEconomicIndicatorsMapper.insert(industrialEconomicIndicators);
        return industrialEconomicIndicators;
    }

    /**
     * 修改数据
     *
     * @param industrialEconomicIndicators 实例对象
     * @return 实例对象
     */
    @Override
    public IndustrialEconomicIndicators update(IndustrialEconomicIndicators industrialEconomicIndicators) {
        this.industrialEconomicIndicatorsMapper.update(industrialEconomicIndicators);
        return this.queryById(industrialEconomicIndicators.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.industrialEconomicIndicatorsMapper.deleteById(id) > 0;
    }
    
     /**
     *  批量添加数据
     * @param list
     * @return 是否成功
     */
    @Override
    public boolean insertBatch(List<IndustrialEconomicIndicators> list) {
        return this.industrialEconomicIndicatorsMapper.insertBatch(list)>0;
    }

    @Override
    public boolean removeByIndicator(Date date, String name) {
        return industrialEconomicIndicatorsMapper.removeByIndicator(date,name);
    }

    /**
     * 根据日期删除
     * @param date
     * @return 是否成功
     */
    @Override
    public boolean removeByDate(Date date) {
        return industrialEconomicIndicatorsMapper.removeByDate(date);
    }
}
